<template>
  <v-app id="app">
    <!-- 导航栏 -->
    <TopNavBar/>
    <!-- 侧边导航栏 -->
    <SideNavBar/>
    <!-- 内容 -->
    <v-content>
      <router-view :key="$route.fullPath" />
    </v-content>
    <!-- 页脚 -->
    <Footer/>
    <!-- 返回顶部 -->
    <BackTop />
    <!-- 搜索模态框 -->
    <SearchModel />
    <!-- 登录模态框 -->
    <LoginModel />
    <!-- 注册模态框 -->
    <RegisterModel />
    <!-- 忘记密码模态框 -->
    <ForgetModel />
    <!-- 绑定邮箱模态框 -->
    <EmailModel />
    <!-- 音乐播放器 设置为0 禁用音乐播放器或者注释掉Player组件-->
    <Player v-if="blogInfo.websiteConfig.isMusicPlayer === 1 && !isMobile" />
    <!-- 聊天室 -->
    <ChatRoom v-if="blogInfo.websiteConfig.isChatRoom === 1"/>
  </v-app>
</template>

<script>
import TopNavBar from "./components/layout/TopNavBar";
import {getBlogInfo} from "@/api/info";
import SideNavBar from "@/components/layout/SideNavBar";
import Footer from "@/components/layout/Footer";
import ChatRoom from "@/components/chat/ChatRoom";
import BackTop from "@/components/backTop/BackTop";
import SearchModel from "@/components/modalBox/SearchModel";
import LoginModel from "@/components/modalBox/LoginModel";
import EmailModel from "@/components/modalBox/EmailModel";
import RegisterModel from "@/components/modalBox/RegisterModel";
import Player from "./components/zw-player/player.vue";
import ForgetModel from "@/components/modalBox/ForgetModel";
export default {
  created() {
    // 获取博客信息
    this.getBlogInfo();
    // 上传访客信息
    this.axios.post("/api/report");
  },
  components: {
    ForgetModel,
    RegisterModel,
    EmailModel,
    LoginModel,
    SearchModel,
    BackTop,
    ChatRoom,
    Footer,
    SideNavBar,
    TopNavBar,
    Player,
  },
  methods: {
    getBlogInfo() {
      getBlogInfo().then(({data}) => {
        this.$store.commit("checkBlogInfo", data.data);
      })
    }
  },
  computed: {
    blogInfo() {
      return this.$store.state.blogInfo;
    },
    isMobile() {
      const flag = navigator.userAgent.match(
          /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
      );
      return flag;
    }
  }
};
</script>
